package org.kzwl.book.controller;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfiguration  {
    @Bean
    public Docket createRestApi1() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(Boolean.FALSE)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.kzwl.book.controller.app"))
                .paths(PathSelectors.any())
                .build()
                .groupName("移动端");
    }
    @Bean
    public Docket createRestApi2() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(Boolean.FALSE)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.kzwl.book.controller.web"))
                .paths(PathSelectors.any())
                .build()
                .groupName("webPC");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("图书")
                .description("图书接口文档")
                .termsOfServiceUrl("http://localhost:1222/")
                .version("1.0")
                .build();
    }


}
